home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 460_01 / YACL0160.ZIP / uidemo / hello2 / appwin.cxx next >
Encoding:
C/C++ Source or Header  |  1996-04-26  |  1.1 KB  |  43 lines

  1.  
  2. // --------------------------- appwin.cxx --------------------------------
  3.  
  4. #include "appwin.h"
  5. #include "ui/stddlg.h"
  6. #include "ui/applic.h"
  7.  
  8. enum {
  9.     ID_BUTTON = 10
  10.   , ID_LABEL  = 11
  11. };
  12.  
  13. AppWindow::AppWindow()
  14. : UI_CompositeVObject (NULL, UI_Rectangle (40, 40, 400, 200))
  15. {
  16.     _count = 5;
  17.     _msg   = new UI_Label (this, UI_Rectangle (55, 55, 245, 20), ID_LABEL);
  18.     _btn   = new UI_PushButton (this, UI_Rectangle (75, 85, 225, 50),
  19.                                 ID_BUTTON);
  20.     _msg->Title() = "Hello!";
  21.     _btn->Title() = "Click here " + CL_String(_count) + " times.";
  22.     Title()       = "YACL Demo";
  23. }
  24.  
  25. bool AppWindow::HandleChildEvent (const UI_Event& e)
  26. {
  27.     if (e.Origin()->ViewID() == ID_BUTTON && e.Type() == Event_Select) {
  28.         _count--;
  29.         if (_count == 0)
  30.             _Application->Destroy (this);
  31.         else
  32.             _btn->Title () (11,1) =  CL_String(_count);
  33.         return TRUE;
  34.     }
  35.     return FALSE;
  36. }
  37.  
  38. bool AppWindow::WantToQuit()
  39. {
  40.     return (UI_StandardDialog ("Do you really want to quit?", "Confirm", NULL,
  41.                                UIS_YesNo, UIS_Question) == UI_IDYES);
  42. }
  43.